package com.study.service.impl;

import com.github.pagehelper.PageHelper;
import com.study.dao.BookMapper;
import com.study.pojo.Book;
import com.study.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;


/**
 * @Author Miss kun
 * @Date 2020/9/23 17:26
 * @Version 1.0
 */
@Service
public class BookServiceImpl implements BookService {

    /**
     * 调用dao层的方法
     */
    @Autowired
    private  BookMapper bookMapper  ;



    @Override
    public int addBook(Book book) {
        return bookMapper.addBook(book);
    }

    @Override
    public List<Book> getBookById(Book book) {
        return bookMapper.getBookById(book);
    }


    @Override
    public List<Book> getChaptersByBookId(Integer id) {
        return bookMapper.getChaptersByBookId(id);
    }

    @Override
    public List<Book> getBooks() {
        return bookMapper.getBooks((1));
    }

    @Override
    public Integer getCount() {
        return bookMapper.getCount();
    }

    @Override
    public Book getChapterById(Integer bookId, Integer chapterId) {
        return bookMapper.getChapterById(bookId,chapterId);
    }

    @Override
    public List<Book> getBookByPage(int page, int size,String type) {
        page = (page-1)*size;
        return bookMapper.getBookByPage(type,page);
    }

    @Override
    public Integer getCountByType(String type) {
        return bookMapper.getCountByType(type);
    }

    @Override
    public List<Book> getBookByLike(String name,int page,int size) {
        page = (page-1)*size;
        return bookMapper.getBookByLike(name,page,size);
    }

    @Override
    public Integer getCountByLikes(String name) {
        return bookMapper.getCountByLikes(name);
    }

    @Override
    public List<Book> getBookByRankList() {
        return bookMapper.getBookByRankList();
    }

    @Override
    public List<Book> getBookRankByType(String type) {
        return bookMapper.getBookRankByType(type);
    }
    /*    @Override
    public int deleteBookById(Integer id) {
        return bookMapper.deleteBookById(id);
    }

    @Override
    public int updateBook(Books book) {
        return bookMapper.updateBook(book);
    }

    @Override
    public Books queryBookById(Integer id) {
        return bookMapper.queryBookById(id);
    }

    @Override
    public List<Books> queryByAllBooks() {
        return bookMapper.queryByAllBooks();
    }

    @Override
    public List<Books> queryBookByName(String name) {
        return bookMapper.queryBookByName(name);
    }

    public BookServiceImpl() {
    }

    *//**
     * 添加set和get方法，用于spring依赖注入
     * @return
     *//*

    public BookMapper getBookMapper() {
        return bookMapper;
    }

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }
    */
}


